from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer

from cart.models import CartModel


class CartSer(ModelSerializer):
    coulist=SerializerMethodField(read_only=True)
    def get_coulist(self,obj):
        return {'name':obj.course.name,'price':obj.course.price,'cover':obj.course.cover,'type':obj.course.level}
    class Meta:
        model = CartModel
        fields = '__all__'
